package com.example.mybank.kafka;

import com.example.mybank.entity.Orders;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.stream.ObjectRecord;
import org.springframework.data.redis.connection.stream.RecordId;
import org.springframework.data.redis.connection.stream.StreamRecords;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Component;

@Component
@Slf4j
// 生产者（消息发送者）
public class Producer {

    @Autowired
    private KafkaTemplate<String, String> kafkaTemplate;


    public void sendRecord(Orders orders) {
        kafkaTemplate.send(ConstString.TOPIC,orders.getId().toString());
        log.info("生成订单, ordersId={}",orders);
    }


}

